﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FilterData
{
    public class FilterDataManager : IFilterData   //Decorator ( luu y o day can chu y thu tu Filter )
    {
        List<IFilterData> ListFilter;
        public FilterDataManager()
        {
            ListFilter = new List<IFilterData>();
            //ListFilter.Add(new FilterEncrypt());
            ListFilter.Add(new FilterSize());
        }
        public byte[] ProcessDataSend(byte[] data)
        {
           byte[] ResultDataSend = data;           
           for (int i = 0; i < ListFilter.Count;i++ )
           {
               ResultDataSend = ListFilter[i].ProcessDataSend(ResultDataSend);
           }
           return ResultDataSend;
        }
        public byte[] ProcessDataReceive(byte[] data)
        {
            byte[] ResultDataReceive = data;
            for (int i = ListFilter.Count - 1; i >=0; i--)
            {
                ResultDataReceive = ListFilter[i].ProcessDataReceive(ResultDataReceive);
            }
            return ResultDataReceive;
        }
    }
}
